;;; A simple feedback state that runs a state, then runs a feedback
;;; state, then returns the ret value of the first state.

(in-package :experiment)

(defvar *feedback-correct-p* nil)

(defclass simple-feedback (state)
  ((state :initarg :state :accessor simple-feedback-state)
   (feedback :initarg :feedback :accessor simple-feedback-feedback)))

(defmethod state-run (experiment (state simple-feedback))
    (let ((*feedback-correct-p* (state-run experiment (simple-feedback-state state))))
      (state-run experiment (simple-feedback-feedback state))
      *feedback-correct-p*))

(defmethod compile-state (experiment (state (eql 'simple-feedback)) args)
  (destructuring-bind (&key ((:state fb-state) nil) feedback) args
    (make-instance state
		   :parent experiment
		   :width (gwee:view-width experiment)
		   :height (gwee:view-height experiment)
		   :state (compile-state experiment (car fb-state) (cdr fb-state))
		   :feedback (compile-state experiment (car feedback) (cdr feedback)))))
